<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
	
	<f:view id="order_cancellation_overview">
		<head>
			<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		</head>
		<body>
			<ui:composition template="main-template.xhtml">
				
				<ui:define name="metadata">
					<f:metadata>
						<f:event type="javax.faces.event.PreRenderViewEvent" listener="#{subscriptionBean.preRenderOverview}"/>
					</f:metadata>
				</ui:define>
				<ui:define name="title">
					<h:outputText value="#{msg.order_cancellation_overview_title}" />
				</ui:define>
				<ui:define name="content">
					<h:link value="#{msg.newSubscription}" outcome="newSubscription"/>
					<h:messages globalOnly="true" infoClass="globalInfoClass" errorClass="globalErrorClass"/>
					<h:form id="subscriptionOverviewForm">
						<h:dataTable id="subscriptionOverviewTable" value="#{subscriptionBean.allSubscriptionsWithTitle}" 
									 var="subscription" rowClasses="rowClassOdd,rowClassEven" headerClass="headerClass">
							<f:facet name="header">
								<h:outputText value="#{msg.order_cancellation_overview_table_heading}" />
							</f:facet>
							<h:column>	
								<f:facet name="header">
									<h:outputText value="#{msg.order_cancellation_overview_column_periodical}" />
								</f:facet>						
								<h:outputText value="#{subscription.periodical.title}" />
							</h:column>
							<h:column>
								<f:facet name="header">
									<h:outputText value="#{msg.order_cancellation_overview_column_action}" />
								</f:facet>	
								<h:link value="#{msg.order_cancellation_overview_editEntry}" outcome="editEntry" >
									<f:param name="subscription_id" value="#{subscription.id}" />
								</h:link>
							</h:column>
						</h:dataTable>
					</h:form>
				</ui:define>
				<ui:define name="foot-nav">
					<!-- dataTable: call bean method that creates a list with all letters for which subscriptions exist (periodical title) -->
					<!-- for every letter create a link, create param for link containing the letter - link opens same page with different data -->
					<ui:repeat var="letter" value="#{subscriptionBean.startLetters}">
						<h:link value="#{letter}" id="index_letter" outcome="orderCancelOverview">
							<f:param name="starts_with" value="#{letter}" />
						</h:link>
					</ui:repeat>
				</ui:define>
			</ui:composition>
		</body>
	</f:view>	
</html>